#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
  printf("I am runing ....\n");

  pid_t id = fork();
  if(id == 0)
  {
    //child
    //int count = 5;
    //while(count)
    while(1)
    { 
      printf("I am child,pid: %d,ppid: %d\n",getpid(),getppid());
      sleep(1);
    }
    printf("child quit ....\n");
    exit(1);
  }
  else if(id>0){
    //father
    int count =5;
   // while(1)
   while(count)
    {
      printf("I am father,pid: %d,ppid: %d\n",getpid(),getppid());
      sleep(1);
      count--;
    }
    exit(0);
  }
  //while(1)
  //{
  //  printf("hello bit!\n");
  //  sleep(1);
  //}
 // printf("Process is runing !\n");

 // sleep(100);

 // printf("Process running done!\n");
//  printf("I am running ...\n");
//  pid_t id = fork();
//  printf("pid: %d\n",id);
//  if(id ==0){
//    while(1){
//      printf("do something!\n");
//      sleep(1);
//    }
//  }
//  else if(id > 0){
//    while(1){
//      printf("call child, do something!\n");
//      sleep(2);
//    }
//  }
//  else{
//    //fork error!
//  }
  
  //while(1){
  //printf("I am a process: pid: %d, ppid: %d\n",getpid(),getppid());
    //sleep(1);
  //}

  return 0;
}
